<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
    </style>
</head>
<body>
    <h1>用户列表</h1>
    <table id="userTable">
        <thead>
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>GitHub</th>
                <th>权限</th>
                <th>博客数</th>
                <th>创建时间</th>
                <th>更新时间</th>
            </tr>
        </thead>
        <tbody id="userTableBody">
        </tbody>
    </table>

    <script src="js/jquery.min.js"></script>
    <script src="js/common.js"></script>
    <script type="text/javascript">
        $.ajax({
            type: "get",
            url: "/user/getUserList",
            success: function(result) {
                if (result.code === "SUCCESS" && result.data != null) {
                    let list = result.data;
                    console.log(result);
                    console.log(list);
                    let finalHtml = "";
                    for (let userInfo of list){
                        finalHtml += '<tr>';
                        finalHtml += '<td>' + userInfo.id + '</td>';
                        finalHtml += '<td>' + userInfo.userName + '</td>';
                        finalHtml += '<td>' + userInfo.githubUrl + '</td>';
                        finalHtml += '<td>' + userInfo.powerStatus + '</td>';
                        finalHtml += '<td>' + userInfo.blogCount + '</td>';
                        finalHtml += '<td>' + userInfo.createTimeStatus + '</td>';
                        finalHtml += '<td>' + userInfo.updateTimeStatus + '</td>';
                        finalHtml += '</tr>';
                    }
                    $("#userTableBody").html(finalHtml);
                }
            },error:function (error){
                if (error != null && error.status === 401){
                    location.href = "blog_login.html";
                }
            }
        });
    </script>
</body>
</html>